package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class Loan here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Loan
{
    // instance variables - replace the example below with your own
    private long id;
    private String borrowDate;
    private int period; //borrow period expressed in days
    private ArrayList<Copy> dvds;
    private Person owner;

    /**
     * Constructor for objects of class Loan
     */
    public Loan()
    {
        // initialise instance variables
        id = 0;
        borrowDate = "";
        period = 0;
        dvds = new ArrayList<Copy>();
        owner = new Person();
    }
    
    public Loan(long _id, String _borrowDate, int _period)
    {
        id = _id;
        borrowDate = _borrowDate;
        period = _period;
    }

    /**
     * An example of a method - replace this comment with your own
     * 
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y 
     */
    public void setId(long _id)
    {
        // put your code here
        id = _id;
    }
    
    public long getId()
    {
        return id;
    }
    
    public void setBorrowDate(String _borrowDate)
    {
        borrowDate = _borrowDate;
    }
    
    public String getBorrowDate()
    {
        return borrowDate;
    }
    
    public void setPeriod(int _period)
    {
        period = _period;
    }
    
    public int getPeriod()
    {
        return period;
    }
    
    public void addCopy(Copy _copy)
    {
        dvds.add(_copy);
    }
    
    public Copy getCopy(long _copyId)
    {
        Copy c = new Copy();
        c = null;
        for (int i=0; i<dvds.size(); i++)
        {
            if (dvds.get(i).getSerialNumber() == _copyId)
            {
                c=dvds.get(i);
            }
            else
                c = null;
        }
        
        return c;
    }
    
    public void setOwner(Person _person)
    {
        owner = _person;
    }
    
    public Person getOwner()
    {
        return owner;
    }
}
